import { Provide } from '@midwayjs/core';
import { Repository } from 'typeorm';
import { TradeEntity } from '../entity/trade.entity';
import { InjectEntityModel } from '@midwayjs/typeorm';

@Provide()
export class TradeService {
  @InjectEntityModel(TradeEntity)
  tradeModel: Repository<TradeEntity>;

  async add(data: any) {
    return await this.tradeModel.save(data);
  }

  async list() {
    return await this.tradeModel.find();
  }

  async info(id: number) {
    return await this.tradeModel.findOne({ where: { id } });
  }

  async del(id: number) {
    return await this.tradeModel.delete(id);
  }
}
